package com.hg.miaosha.common.enums;

import lombok.Getter;

/**
 * 秒杀状态类型枚举
 */
@Getter
public enum SeckillEnums {
	SECKILL_SUCCESS(0,"秒杀成功"),
	SECKILL_ERROR_WITH_NO_STOCK(10001,"库存不足,秒杀失败"),
	SECKILL_ERROR_WITH_GOODS_NOT_FOUND(10002,"商品不存在,秒杀失败")

	;

	private Integer code;
	private String message;

	SeckillEnums(Integer code, String message) {
		this.code = code;
		this.message = message;
	}
	
	public static SeckillEnums stateOf(int index) {
		for (SeckillEnums state : values()) {
			if (state.getCode() == index) {
				return state;
			}
		}
		return null;
	}
}